#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <sys/wait.h>
int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    int cnt = 5;
    while(cnt--)
    {
      printf("I am a child process,pid:%d\n",getpid());
      sleep(1);
    }
    exit(0);
  }

  else if(id > 0)
  {
    pid_t rid = wait(NULL);
    if(rid == id)
    {
      printf("pid:%d,wait success!\n",getpid());
    }
  }

  return 0;
}
